<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-11-28 14:47
 *
 * Version: 2.0
 */

namespace App\Modules\RedBag\Controllers;


use App\Lib\Facades\FLAuth;
use App\Modules\RedBag\Services\RedBagService;
use Flower\Core\Http\BaseController;
use Illuminate\Http\Request;

class RedBagMemberController extends BaseController
{
	protected  $redBagService;
	public function __construct(RedBagService $redBagService)
	{
		$this->redBagService = $redBagService;
	}

	/**
	 * 抢红包
	 * @param Request $request
	 * @return mixed
	 * @throws \App\Exceptions\NotFoundException
	 */
	public function pickUp(Request $request){
		$id = $request->input('id');
		$source = $request->input('source',0);
		$result = $this->redBagService->pickUpRedBag($id,FLAuth::id(),$source);
		return $this->handleApiResult($result);
	}

	/**
	 * 红包列表
	 * @param Request $request
	 * @return mixed
	 */
	public function lst(Request $request){
		$regBagId = $request->input('id');
		$live_id = $request->input('live_id');
		$result = $this->redBagService->lst($regBagId,$live_id);
		return $this->handleApiResult($result);
	}


	/**
	 * 检测是否发红包
	 * @param Request $request
	 * @return mixed
	 */
	public function checkHasRedBag(Request $request){
		$user_id = $request->input('user_id');
		$store_id = $request->input('store_id');
		$member_id = FLAuth::id();
		$result = $this->redBagService->checkHasRedBag($user_id,$store_id,$member_id);
		return $this->handleApiResult($result);
	}

}